package com.his.controller;

import com.his.bean.DzmHisDepartment;
import com.his.service.DzmHisDepartmentService;
import com.his.utils.ResponseResult;
import org.aspectj.apache.bcel.classfile.Code;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dzmhisdepartments")
public class DzmHisDepartmentController {
    @Autowired
    DzmHisDepartmentService dzmHisDepartmentService;

    @GetMapping("/select")
    public ResponseResult selectAll(DzmHisDepartment dzmHisDepartment) {
        System.out.println(dzmHisDepartment);
        List<DzmHisDepartment> list = dzmHisDepartmentService.selectAll(dzmHisDepartment);

        return new ResponseResult(200, "成功", list);
    }
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody DzmHisDepartment dzmHisDepartment){
         dzmHisDepartmentService.add(dzmHisDepartment); 
         return new ResponseResult(200,"成功");
    }
    @DeleteMapping("/deletes/{did}")
    public ResponseResult delete(@PathVariable Integer did){
        System.out.println(did+"删除的id");
        dzmHisDepartmentService.delete(did);
        return new ResponseResult(200,"成功");
    }

    @PostMapping("/updates")
    public ResponseResult update(@RequestBody DzmHisDepartment dzmHisDepartment){
        dzmHisDepartmentService.update(dzmHisDepartment);
        return new ResponseResult(200,"成功");
    }

    @GetMapping("/selectById/{did}")
    public ResponseResult selectById(@PathVariable Integer did){
        DzmHisDepartment dzmhisdepartment = dzmHisDepartmentService.selectById(did);
        return new ResponseResult(200,"成功",dzmhisdepartment);
    }

}
